package com.shy.springframework.test.bean;


import com.shy.springframework.beans.factory.annotation.Autowired;
import com.shy.springframework.beans.factory.annotation.Qualifier;
import com.shy.springframework.beans.factory.annotation.Value;
import com.shy.springframework.stereotype.Component;

import java.util.Random;

/**
 * @author yzpang
 * @desc:
 * @date: 2023/2/7 13:43
 */
@Component(value = "userService")
public class UserService implements IUserService {
    @Value("${token}")
    private String token;

    @Value("${uid}")
    private String uid;
    @Autowired
/*    @Qualifier(value = "userDao")*/
    private IUserDao userDao;

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    @Override
    public String toString() {
        return "UserService{" +
                "token='" + token + '\'' +
                '}';
    }

    public String  queryUserInfo(){
        return "查询用户: " + userDao.queryUserInfo(uid);
    }

    @Override
    public String registerName(String userName) {
        try {
            Thread.sleep(new Random().nextInt(100));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("方法执行: registerName");
        return "注册用户: " + userName;
    }
}
